package com.wang.controller;


import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
public class AjaxController {

    @RequestMapping("/a1")
    public void test(String name, HttpServletResponse response) throws IOException {

        response.setCharacterEncoding("utf-8");
        if(name.equals("wang")){
            response.getWriter().print("正确");
        }
        else response.getWriter().print("错误");

    }
    @RequestMapping("/au")
    public String test2(String username){
       if(username==null){
           return "用户名不能为空";
       }
       else if (username.equals("admin")){
           return "ok";
       }
       else return "x";
    }

    @RequestMapping("/ap")
    public String test3(String password){
        if(password==null){
            return "密码不能为空";
        }
        else if (password.equals("123456")){
            return "ok";
        }
        else return "x";
    }

}
